package com.sd.mapper;

import com.sd.domain.Assistant;
import com.sd.domain.ImCollect;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author yexinming
 * @date 2020/3/12
 **/
@Mapper
public interface AssistantMapper {
    /**
     * 保存
     * @param assistant 助理对象
     */
    @Insert("insert into assistant(" +
                "user_name," +
                "phone," +
                "parent_id," +
                "parent_phone," +
                "nick_name," +
                "parent_name," +
                "is_valid," +
                "remark," +
                "create_time," +
                "update_time," +
                "partnerid" +
            ") values(" +
                "#{userName}," +
                "#{phone}," +
                "#{parentId}," +
                "#{parentPhone}," +
                "#{nickName}," +
                "#{parentName}," +
                "#{isValid}," +
                "#{remark}," +
                "#{createTime}," +
                "#{updateTime}," +
                "#{partnerid}" +
            ")")
    void save(Assistant assistant);
    /**
     * 查询校董助理
     * @param xxl_sso_sessionid
     * @return
     */
    @Select("select " +
                "user_name," +
                "phone," +
                "parent_id," +
                "parent_phone," +
                "parent_name," +
                "nick_name," +
                "is_valid," +
                "remark," +
                "create_time," +
                "update_time," +
                "partnerid " +
            "from assistant " +
            "where partnerid = #{partnerid}")
    @Results({
            @Result(column = "user_name", property = "userName"),
            @Result(column = "phone", property = "phone"),
            @Result(column = "parent_id", property = "parentId"),
            @Result(column = "parent_phone", property = "parentPhone"),
            @Result(column = "parent_name", property = "parentName"),
            @Result(column = "nick_name", property = "nickName"),
            @Result(column = "is_valid", property = "isValid"),
            @Result(column = "remark", property = "remark"),
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "update_time", property = "updateTime"),
            @Result(column = "partnerid", property = "partnerid")
       }
    )
    Assistant findByAuthCode(@Param("partnerid") String xxl_sso_sessionid);

    /**
     * 删除助理
     * @param xxl_sso_sessionid
     * @return
     */
    @Delete("delete from assistant where partnerid = #{partnerid}")
    void removeByAuthCode(@Param("partnerid") String xxl_sso_sessionid);
}
